// #include FT_FREETYPE_H 
// Std. Includes
// #include <iostream>
// #include <map>
// #include <string>
// #include <locale.h>
// #include <wchar.h>
// // GLEW
// #define GLEW_STATIC
// #include <GL/glew.h>
// #include <GL/freeglut.h> // 包含OpenGL头文件
// // GLFW
// #include <GLFW/glfw3.h>
// // GLM
// #include <glm/glm.hpp>
// #include <glm/gtc/matrix_transform.hpp>
// #include <glm/gtc/type_ptr.hpp>
// // FreeType
// //字体库头文件
// #include <ft2build.h>
// #include <freetype/config/ftheader.h>
// #include <freetype/ftglyph.h>
// #include FT_FREETYPE_H
// GL includes
// #include "Shader.h"

// #include <FreeImage.h>

#include <assgl.h>
// #include "assglOpengl.h"

// The MAIN function, from here we start our application and run the Game loop
int main()
{
    AssglLib* lib = assgl_read_file("../www.ass");
    printf( "PlayResX:%d\n" , lib->PlayResX );
    printf( "PlayResY:%d\n" , lib->PlayResY );
    
    wprintf( "Text:%s\n" , lib->AssglTrackItem[0].Text );
    openglInit(lib);
    AssglImage * bitmap = assgl_render_frame(lib,5);

#if 0
    //============test 1===========
    FIBITMAP *fibitmap = (FIBITMAP *)malloc( sizeof(FIBITMAP));
    fibitmap->data = malloc(sizeof(unsigned char)*lib->AssglTrackItem[lib->AssglTrackCounts].GlPicturePa.BufferSize);
    // fibitmap->data = bitmap->bitmap;
    memcpy(fibitmap->data,bitmap->bitmap,lib->AssglTrackItem[lib->AssglTrackCounts].GlPicturePa.BufferSize);
    FreeImage_Save(FIF_PNG, fibitmap, "testpng.png", 0);
    //============test 1 end===========
#endif    
    //============test 2===========
    FILE *fd = fopen("testpng6.png","w+");
    fwrite(bitmap->bitmap,bitmap->stride,1,fd);
    fclose(fd);
    //============test 2 end===========
 
    return 0;
}
